//
//  FTUtils_ScreenShot.m
//  FTUtils_ScreenShot
//
//  Created by JackieYip on 2017/6/11.
//  Copyright © 2017年 mondial-d. All rights reserved.
//

#import "FTUtils_ScreenShot.h"
#import "FTInternationalization_Macro.h"
#import "FTMacro_Font.h"

@implementation FTUtils_ScreenShot
+ (UIImageView *)imageViewShotOfView:(UIView *)view
{
    UIView *cutView = view;
    // 开启上下文,使用参数之后,截出来的是原图（YES  0.0 质量高）
    UIGraphicsBeginImageContextWithOptions(cutView.frame.size, YES, 0.0);
    // 将cutView的图层渲染到上下文中
    [cutView drawViewHierarchyInRect:cutView.frame afterScreenUpdates:NO];
    // 取出UIImage
    UIImage *cutImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:cutImage];
    return imageView;
}

+ (UIImageView *)imageViewShotOfInternationalizationSettingView:(UIView *)view
{
    UIImageView *imageView = [self imageViewShotOfView:view];
    
    imageView.userInteractionEnabled = YES;
    
    // tips
    UILabel *tips = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 80)];
    tips.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.8];
    tips.textColor = [UIColor whiteColor];
    tips.center = imageView.center;
    tips.layer.cornerRadius = 5.0;
    tips.layer.masksToBounds = YES;
    tips.textAlignment = NSTextAlignmentCenter;
    tips.font = kFont16;
    tips.text = FTLocalizedStringInLocalizable(@"正在设置...");
    
    [imageView addSubview:tips];
    
    return imageView;
}
@end
